
//anhlx creater
//
//

function menu() {
    var page_wrap = $('#page-wrap');
    var page_tray = $('#page-tray');

    page_tray.width($('#page-content').width());
    setTimeout(function() {
        page_tray.addClass('transition');
    }, 100);

    $(window).resize(function() {
        page_tray.width(page_wrap.width() + (page_wrap.hasClass('show-user-panel') ? 225 : 0));
    });

    $('#user-panel-toggle').click(function() {

        if (page_wrap.hasClass('show-user-panel')) {
            
            page_tray.width(page_tray.width() - 225);
            page_wrap.removeClass('show-user-panel');
            setTimeout(function() {
                $('.slide-page.wd-fix').css('position','fixed');
                $('.slide-page.wd-fix').css('width','100%');
                $('.slide-page.wd-fix').css('bottom','0');
                 $(".slide-page").show();
            }, 500);
           
        } else {
            
            page_tray.width(page_tray.width() + 225);
            page_wrap.addClass('show-user-panel');
            $('.slide-page.wd-fix').css('position','static');
            $(".slide-page").hide();
        }
    });

    var hW = $(window).height() - $('.wd-menu-name').height() - $('.wd-padding').height() - 120;

    $("#user-menu").slimscroll({
        distance: '0px',
        size: '4px',
        color: '#8b8a8b',
        railColor: '#fff',
        alwaysVisible: true,
        allowPageScroll: false,
        width: '225px',
        height: hW + 'px',
        railVisible: true,
        railOpacity: 1
    }).parent().css({
        });

}

function focusText() {
    $('input[type="text"]').focus(function() {
        $(this).css("color", "#9A7E72");
        if (this.value == this.defaultValue) {
            this.value = '';
        }
        if (this.value != this.defaultValue) {
            this.select();
        }
    }).blur(function() {
        if (jQuery.trim(this.value) == '') {
            this.value = (this.defaultValue ? this.defaultValue : '');
            $('.reset-text-ico').hide();
        }
        if (this.value == this.defaultValue) {

        }
    });
}

jQuery.fn.putCursorAtStart = function()
{
    return this.each(function()
    {
        jQuery(this).focus()

        // If this function exists...
        if (this.setSelectionRange)
        {
            // ... then use it
            // (Doesn't work in IE)

            // Double the length because Opera is inconsistent about whether a carriage return is one character or two. Sigh.
            var len = jQuery(this).val().length * 2;
            this.setSelectionRange(len, 0);
        }
        else
        {
            // ... otherwise replace the contents with itself
            // (Doesn't work in Google Chrome)
            jQuery(this).val(jQuery(this).val());
        }

        // Scroll to the bottom, in case we're in a tall textarea
        // (Necessary for Firefox and Google Chrome)
        this.scrollTop = 999999;
    });
};

$(window).resize(function() {
    setWidthImage();
});

function setWidthImage() {
    var winW = 950, winH = 600;
    if (document.body && document.body.offsetWidth) {
        winW = document.body.offsetWidth;
        winH = document.body.offsetHeight;
    }
    if (document.compatMode == 'CSS1Compat' &&
        document.documentElement &&
        document.documentElement.offsetWidth) {
        winW = document.documentElement.offsetWidth;
        winH = document.documentElement.offsetHeight;
    }
    if (window.innerWidth && window.innerHeight) {
        winW = window.innerWidth;
        winH = window.innerHeight;
    }

    var ratio = 640 / 340;
    $(".couple").css({
        "width": winW,
        "height": winW / ratio
    });

    $('.img-couple').css({
        "width": winW,
        "height": winW / ratio
    });
}

$(function() {
    setWidthImage();
});
var current_banner = 14;
$(function() {
    menu();
    //focusText();
   // bannerRotator('#bannerRotator', 500, 8000);
    
//        var hW = $(window).height();
//        var dH = $('body').height();
//        alert(hW + '==' + dH);
//        if(dH > hW) {
//            $('body').css('margin-bottom','56px');
//        }
//    
//        $(window).resize(function() {
//            if(dH > hW) {
//                $('body').css('margin-bottom','56px');
//            } else {
//                $('body').css('margin-bottom','0');
//            }
//        }); 
    //hanv
    if (typeof(Storage) !== "undefined")
    {   
//        facebook_token = localStorage.facebook_token;
//        if (facebook_token !== "") {
//            var config = {
//                app_id: '470782169676577', //fill app id
//                secret: '3154b2dfb96125e3bc52fb693a17e67c',
//                scope: 'email,user_birthday,status_update,publish_stream,user_about_me',
//                host: 'http://www.iclickapps.com/weddinghelper/Client/www/login.html'
//            };
//            var facebook_graph = "https://facebook.com";
//            var url_logout = facebook_graph + "/logout.php?access_token=" + facebook_token + "&confirm=1&next=" + config.host;
//            $('#logout').attr("href", url_logout);
//        }
        //fill name in menu       
        $(".wd-menu-name").html(localStorage.firstName+" "+localStorage.lastName);
        
    }
    else
    {
        return false;
    }
});

